package org.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.entity.Test;

import java.util.List;

/**
 * <p>
 * 测试 Mapper 接口
 * </p>
 *
 * @author yangzhenyu
 * @since 2023-04-24 05:20:03
 */
@Mapper
public interface TestMapper extends BaseMapper<Test> {
    @Select("<script>" +
            "select * \n" +
            "from test \n" +
            "where mod(id, #{shardingTotalCount}) = #{shardingItem} \n" +
            "  and id &gt;= #{beginId} \n" +
            "  limit  #{limitPage}\n" +
            "</script>")
    List<Test> query(Long beginId, int shardingItem, int shardingTotalCount,int limitPage);

    /**
     * 查询最大id
     *
     * @return
     */
    @Select("select max(id) from test")
    Long queryMaxId();
}
